<script setup lang="ts">
import { ref, onMounted, onBeforeMount } from "vue";
import dayjs from 'dayjs'
import Gender from "@/view/Panel/components/left/Gender.vue";
import Map from "@/view/Panel/components/center/Map.vue"
import Article from "@/view/Panel/components/left/Article.vue";
import Course from "@/view/Panel/components/right/Course.vue";
import Satisfie from "@/view/Panel/components/right/Satisfie.vue";

// 计时器
let nowTime = ref()
let timer = ref(0)

onMounted(() => {
  timer.value = setInterval(() => {
    const timeStamp = Date.now()
    nowTime.value = dayjs(timeStamp).format('YYYY-MM-DD HH:mm:ss')
  }, 1000)
})

onBeforeMount(() => {
  clearInterval(timer.value)
})
</script>

<template>
  <div class="screen">
    <div class="screen-box">
      <div class="screen-top">
        <div class="screen-top-left">
          <img src="http://img.cgym.fun/web/important/dataScreen-header-btn-bg-l.png" alt="">
          <RouterLink to="/home">
            <span>返回首页</span>
          </RouterLink>
        </div>
        <div class="screen-top-center center">
          <h2>CGYM数据可视化平台</h2>
        </div>
        <div class="screen-top-right">
          <img src="http://img.cgym.fun/web/important/dataScreen-header-btn-bg-r.png" alt="">
          <span class="screen-refresh">刷新数据</span>
          <span class="screen-time">{{ nowTime }}</span>
        </div>
      </div>
      <div class="screen-body">
        <div class="screen-body-left">
          <Gender class="gender"/>
          <Article class="article"/>
        </div>
        <div class="screen-body-center">
          <Map class="map"/>
        </div>
        <div class="screen-body-right">
          <Course class="course"/>
          <Satisfie class="satisfie"/>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.screen {
  width: 100vw;
  height: 100vh;
  display: flex;
  background-color: #565262;
  justify-content: center;

  .screen-box {
    width: 80vw;
    height: 100vh;

    .screen-top {
      display: flex;
      width: 100%;
      height: 55px;

      .screen-top-left {
        width: 20vw;
        display: flex;
        position: relative;
        justify-content: flex-end;
        background: url("http://img.cgym.fun/web/important/dataScreen-header-right-bg.png") no-repeat;

        img {
          height: 35px;
        }

        span {
          position: absolute;
          right: 28px;
          top: 8px;
          font-size: 15px;
          color: white;
        }
      }

      .screen-top-center {
        width: 40vw;
        background: url("http://img.cgym.fun/web/important/dataScreen-header-center-bg.png") no-repeat;
        background-size: cover;

        h2 {
          color: white;
        }
      }

      .screen-top-right {
        width: 20vw;
        position: relative;
        background: url("http://img.cgym.fun/web/important/dataScreen-header-right-bg.png") no-repeat;

        img {
          height: 35px;
        }

        span {
          font-size: 15px;
          color: white;
          position: absolute;
          top: 8px;
        }

        .screen-refresh {
          left: 28px;
          cursor: pointer;
        }

        .screen-time {
          right: 15px;
        }
      }
    }

    .screen-body {
      display: flex;
      flex-direction: row;
      margin-top: 15px;

      .screen-body-left {
        display: flex;
        flex: 1;
        height: calc(100vh - 70px);
        flex-direction: column;

        .article {
          flex: 1;
        }

        .gender {
          flex: 1;
        }

        .age {
          flex: 1;
        }
      }

      .screen-body-center {
        display: flex;
        height: calc(100vh - 70px);
        flex-direction: column;
        box-sizing: border-box;
        padding: 20px 0;
        flex: 1.5;

        .map {
          flex: 2;
        }

        .tendency {
          flex: 1
        }
      }

      .screen-body-right {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: calc(100vh - 70px);

        .course {
          flex: 1;
        }

        .contrast {
          flex: 1;
        }

        .satisfie {
          flex: 1;
        }
      }
    }
  }
}
</style>
